by Gehan Fernando (47 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Wed 7th February 2007
Date Added: Mon 8th February 2021
Rating: (1 Votes)
VB.Net - Use Dataview { Data Type Component } To Filter Data In Very Easy Way. No Need To Write SQL Queries, One SQL Query Enough To Do All
API Declarations
.SqlClient
DataGridView1.DataSource = ReturnDataTable()
End Sub
Public Function ReturnDataTable() As DataTable
Dim SQLCon As New SqlClient.SqlConnection("Data Source=UDEESHA;Initial Catalog=Gehan;Integrated Security=True;Pooling=False")
SQLCon.Open()
Dim SQLCom As New SqlClient.SqlCommand("SELECT * FROM Students", SQLCon)
Dim DSet As New DataSet()
Dim DAdap As New SqlClient.SqlDataAdapter(SQLCom)
DAdap.Fill(DSet)
Return DSet.Tables(0)
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim DView As New DataView(ReturnDataTable())
With DView
.AllowDelete = False
.AllowEdit = False
.AllowNew = False
.RowFilter = "StudName LIKE '" & TextBox1.Text.ToString().Trim() & "%'"
.RowStateFilter = DataViewRowState.OriginalRows
.Sort = "ID"
End With
DataGridView1.DataSource = DView
End Sub
No comments have been posted about VB.Net - Use Dataview { Data Type Component } To Filter Data In Very Easy Way. No Need To Write SQL. Why not be the first to post a comment about VB.Net - Use Dataview { Data Type Component } To Filter Data In Very Easy Way. No Need To Write SQL.